﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Rose.Models.RecommendModel>>" %>
<%@ Import Namespace="Rose.Helper" %>
 
<div id="recommendlist" class="list">



<%--
<div id="searchselect"><p>欧阳的js</p></div>
<div id="sex"><p><input type="checkbox" checked="checked" />异性</p></div>
</div>--%>


<div class="listhead">
<select class='ww'>
<option value="1" selected="selected">同校</option>
<option value="2">本专业</option>
<option value="3">老乡</option>
</select>
<p id="abc"><input type="checkbox" id="haha"  checked="checked" />异性</p>
</div>




<div class="listcontent">
     <%foreach (var item in Model)
     { %>
  <div class="recommend">
<div class="imagepart"><a class="publicalbum" onclick="PublicAlbum(this);" data="<%=item.UserId %>"><img src="<%=item.ImagePath %>" class="headimage" /></a></div>
<div class="infopart"><p class="name"><a href="<%=Url.Action("Friend","FriendTrend",new{friendId=item.UserId}) %>" ><%=item.TrueName %></a></p><p><a href="<%=Url.Action("SearchByCollegeName","Search",new{college=item.College}) %>"><%=item.College+CheckDataHelpModel.FormatSchoolYear(item.SchoolYear)%></a></p></div>
<div class="actionpart"><p><a class="addfriend" onclick="AddFriend(this);" data="<%=item.UserId %>">加为好友</a></p>
<p><a class="addfocus" data="<%=item.UserId %>" onclick="AddFocus(this);">关注TA</a></p>

</div>
</div>
     

   <%} %>

<div class="more"><p><a class="next pointer">换人</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/Search/MoreRecommend">更多</a></p></div>

</div>
<div class="listbottom"></div>


</div>


<script type="text/javascript">
    $(document).ready(function () {
        recommendpostdata = 2;
        $('div#recommendlist div.more a.next').click(function () {
            var type = $('.listhead').find('select').val();
            var isopp = $('#haha').attr('checked');

            $.ajax({ url: '/Home/RecommendJson', data: { currentpage: recommendpostdata++,type:type, isOppGender: isopp }, dataType: 'json', type: 'post', success: function (data) {
                if (data.length > 0) {
                    $('div#recommendlist div.recommend').remove();
                    for (i in data) {

                        $('div#recommendlist div.more').before('<div class="recommend"><div class="imagepart"><a class="publicalbum" onclick="PublicAlbum(this);" data="' + data[i].UserId + '"><img src="' + data[i].ImagePath + '" class="headimage"></a></div><div class="infopart"><p class="name"><a href="/FriendTrend/Friend?friendId=' + data[i].UserId + '">' + data[i].TrueName + '</a></p><p><a href="/Search/SearchByCollegeName?college=' + data[i].College + '">' + data[i].College + data[i].SchoolYear + '</a></p></div><div class="actionpart"><p><a class="addfriend" onclick="AddFriend(this);" data="' + data[i].UserId + '">加为好友</a></p><p><a class="addfocus" onclick="AddFocus(this);" data="' + data[i].UserId + '">关注TA</a></p></div></div>');
                    }
                } //end of if
                else {

                    jAlert('推荐已到最后一页', 'School Party');
                    recommendpostdata = 1;
                    $.ajax({ url: '/Home/RecommendJson', data: { currentpage: recommendpostdata++, type: type, isOppGender: isopp }, dataType: 'json', type: 'post', success: function (data) {

                        $('div#recommendlist div.recommend').remove();
                        for (i in data) {

                            $('div#recommendlist div.more').before('<div class="recommend"><div class="imagepart"><a class="publicalbum" onclick="PublicAlbum(this);" data="' + data[i].UserId + '"><img src="' + data[i].ImagePath + '" class="headimage"></a></div><div class="infopart"><p class="name"><a href="/FriendTrend/Friend?friendId=' + data[i].UserId + '">' + data[i].TrueName + '</a></p><p><a href="/Search/SearchByCollegeName?college=' + data[i].College + '">' + data[i].College + data[i].SchoolYear + '</a></p></div><div class="actionpart"><p><a class="addfriend" onclick="AddFriend(this);" data="' + data[i].UserId + '">加为好友</a></p><p><a class="addfocus" onclick="AddFocus(this);" data="' + data[i].UserId + '">关注TA</a></p></div></div>');
                        }
                    } //end of success

                    });
                } //end of else
            }
            });
        });

    });
</script>
<script type="text/javascript">
    (function ($) {
        function hideOptions(speed) {
            if (speed.data) { speed = speed.data }
            if ($(document).data("nowselectoptions")) {
                $($(document).data("nowselectoptions")).slideUp(speed);
                $($(document).data("nowselectoptions")).prev("div").removeClass("tag_select_open");
                $(document).data("nowselectoptions", null);
                $(document).unbind("click", hideOptions);
                $(document).unbind("keyup", hideOptionsOnEscKey);
            }
        }
        function hideOptionsOnEscKey(e) {
            var myEvent = e || window.event;
            var keyCode = myEvent.keyCode;
            if (keyCode == 27) hideOptions(e.data);
        }
        function showOptions(speed) {
            $(document).bind("click", speed, hideOptions);
            $(document).bind("keyup", speed, hideOptionsOnEscKey);
            $($(document).data("nowselectoptions")).slideDown(speed);
            $($(document).data("nowselectoptions")).prev("div").addClass("tag_select_open");
        }
        $.fn.selectCss = function (_speed) {
            $(this).each(function () {
                var speed = _speed || "fast";
                if ($(this).data("cssobj")) {
                    $($(this).data("cssobj")).remove();
                }
                $(this).hide();
                var divselect = $("<div><span></span></div>").insertAfter(this).addClass("tag_select");
                $(this).data("cssobj", divselect);
                var divoptions = $("<ul></ul>").insertAfter(divselect).addClass("tag_options").hide();
                divselect.click(function (e) {
                    if ($($(document).data("nowselectoptions")).get(0) != $(this).next("ul").get(0)) {
                        hideOptions(speed);
                    }
                    if (!$(this).next("ul").is(":visible")) {
                        e.stopPropagation();
                        $(document).data("nowselectoptions", $(this).next("ul"));
                        showOptions(speed);
                    }
                });
                divselect.hover(function () {
                    $(this).addClass("tag_select_hover");
                },
				function () {
				    $(this).removeClass("tag_select_hover");
				});
                $(this).change(function () {
                    $(this).nextAll("ul").children("li:eq(" + $(this)[0].selectedIndex + ")").addClass("open_selected").siblings().removeClass("open_selected");
                    $(this).next("div").children('span').html($(this).children("option:eq(" + $(this)[0].selectedIndex + ")").text());
                });
                $(this).children("option").each(function (i) {
                    var lioption = $("<li></li>").html($(this).text()).attr("title", $(this).attr("title")).appendTo(divoptions);
                    if ($(this).attr("selected")) {
                        lioption.addClass("open_selected");
                        divselect.children('span').html($(this).text());
                    }
                    lioption.data("option", this);
                    lioption.click(function () {
                        lioption.data("option").selected = true;
                        $(lioption.data("option")).trigger("change", true)
                    });
                    lioption.hover(
						function () { $(this).addClass("open_hover"); },
						function () { $(this).removeClass("open_hover"); }
					);
                });
            });
        }
    })(jQuery);
</script>

<script type="text/javascript">
    $(document).ready(function () {
        $("select.ww").selectCss();
    });
</script>
